//
//  LocalRepairHistoryDetailMaintenanceCell.m
//  ICrEAM
//
//  Created by ysw on 2016/11/23.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "LocalRepairHistoryDetailMaintenanceCell.h"

@interface LocalRepairHistoryDetailMaintenanceCell ()

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UILabel *codeLabel;

@property (nonatomic, strong) UILabel *repairTypeLabel;

@property (nonatomic, strong) UILabel *workPriceLabel;

@property (nonatomic, strong) UILabel *workTimeLabel;
@end

@implementation LocalRepairHistoryDetailMaintenanceCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        NSDictionary *nameTextDic = @{@"font":TitleFont,@"color":ContentTextColor_Black,@"align":@0};
        NSDictionary *codeTextDic = @{@"font":ContentFont,@"color":ContentTextColor_Gray,@"align":@0};
        NSDictionary *contentTextDic = @{@"font":ContentFont,@"color":ContentTextColor_Black,@"align":@1};
                                      
        UILabel *nameLabel = [self createLabelWithDic:nameTextDic text:@"name" frame:CGRectMake(0, 0, ActualWidth(200), ActualHeight(22))];
        [self.contentView addSubview:nameLabel];
        
        UILabel *codeLabel = [self createLabelWithDic:codeTextDic text:@"code" frame:CGRectMake(ActualWidth(15), nameLabel.bottomEdge, ActualWidth(185), ActualHeight(15))];
        [self.contentView addSubview:codeLabel];
        
        UILabel *repairTypeLabel = [self createLabelWithDic:contentTextDic text:@"eee" frame:CGRectMake(codeLabel.rightEdge, nameLabel.bottomEdge, ActualWidth(140), ActualHeight(15))];
        [self.contentView addSubview:repairTypeLabel];
        
        UILabel *workPriceLabel = [self createLabelWithDic:contentTextDic text:@"333" frame:CGRectMake(repairTypeLabel.rightEdge, nameLabel.bottomEdge, ActualWidth(140), ActualHeight(15))];
        [self.contentView addSubview:workPriceLabel];
        
        UILabel *workTimeLabel = [self createLabelWithDic:contentTextDic text:@"1" frame:CGRectMake(workPriceLabel.rightEdge, nameLabel.bottomEdge, ActualWidth(140), ActualHeight(15))];
        [self.contentView addSubview:workTimeLabel];
        
        self.nameLabel = nameLabel;
        self.codeLabel = codeLabel;
        self.repairTypeLabel = repairTypeLabel;
        self.workPriceLabel = workPriceLabel;
        self.workTimeLabel = workTimeLabel;
        
    }
    return self;
}

#pragma mark 根据model设值
- (void)setupLabelsWithModel:(ICMRepairMaintenanceModel *)model{
    self.nameLabel.text = model.LABOUR_NAME;
    self.codeLabel.text = model.LABOUR_CODE;
    self.repairTypeLabel.text = model.REPAIR_TYPE_NAME;//self.repairType;
    self.workPriceLabel.text = [NSString stringWithFormat:@"%.2f",[model.LABOUR_AMOUNT floatValue]];
    self.workTimeLabel.text = model.STD_LABOUR_HOUR;
}

- (UILabel *)createLabelWithDic:(NSDictionary *)dic text:(NSString *)text frame:(CGRect)frame{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = dic[@"font"];
    label.textColor = dic[@"color"];
    label.textAlignment = [dic[@"align"] integerValue];
    return label;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
